package com.peko.swagger.controller;

import com.peko.swagger.dto.MyParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author Peko
 */
@RestController
@RequestMapping("hello")
@Api(tags = "这是controller的描述")
public class HelloController {

    @ApiOperation(value = "这是hi接口",
            notes = "<span style='color:red;'>描述:</span>&nbsp;这是hi接口的详细描述")
    @GetMapping("hi")
    public String hi(){
        return "hi";
    }

    @PostMapping("bye")
    @ApiImplicitParams({
            //注意：这里的defaultValue是供Swagger的[Try It Out]测试时的默认值
            @ApiImplicitParam(name = "param1",value = "param1参数描述",dataType = "String",defaultValue = "1"),
            @ApiImplicitParam(name = "param2",value = "param2参数描述",dataType = "String",defaultValue = "2")
    })
    public String bye(String param1,String param2){
        System.out.println(param1 + " " +param2);
        return "bye";
    }

    @PostMapping("goodbye/{param1}/{param2}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param1",value = "param1参数描述",dataType = "String",defaultValue = "1",paramType = "path"),
            @ApiImplicitParam(name = "param2",value = "param2参数描述",dataType = "String",defaultValue = "2",paramType = "path")
    })
    public String goodbye(@PathVariable("param1") String param1, @PathVariable("param2") String param2){
        System.out.println(param1 + " " +param2);
        return "goodbye";
    }

    @PostMapping("seeyou")
    public String seeyou(@RequestBody MyParams myParams){
        return "seeyou";
    }
}
